import Vue from 'vue';
import Vuex from 'vuex';
import userInfoModule from './modules/userInfo';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    sysVersion: '1.0.0',
    loginDate: null,
  },
  mutations: {
    upgrade(state, payload) {
      state.sysVersion = payload;
    },
    updateLoginDate(state, date) {
      state.loginDate = date;
    },
  },
  actions: {
    login(context, date) {
      context.commit('updateLoginDate', date);
    },
    upgrade(context) {
      setTimeout(
        () => {
          context.commit('upgrade', '2.0.0');
        },
        1000,
      );
    },
  },
  modules: {
    userInfoModule,
  },
});
